import React from "react"
import HelloWorld from "./HelloWorld"

class App extends React.Component {
    constructor() {
        super()
        this.state = {
            isShowHW: true,
        }
    }
    /* 组件挂载到DOM */
    componentDidMount() {
        console.log("componentDidMount")
    }

    isShowHW() {
        this.setState({
            isShowHW: !this.state.isShowHW,
        })
    }

    render() {
        const { isShowHW } = this.state
        console.log("render")
        return (
            <>
                <div>哈哈哈</div>
                <button onClick={() => this.isShowHW()}>切换</button>

                {isShowHW && <HelloWorld />}
            </>
        )
    }
}

export default App
